﻿using System;
using System.ComponentModel.Composition;
using System.Collections.Generic;
using System.Windows.Forms;

namespace AddinSample
{
    [InheritedExport(typeof(IYnotePlugin))]
    public class SimplePlugin : IYnotePlugin
    {
        /// <summary>
        /// Partial Host. Will Be Set By Ynote AutoMatically
        /// </summary>
        private IYnoteHost partialhost;
        /// <summary>
        /// Interface Host
        /// </summary>
        public IYnoteHost Host { get { return partialhost; } set { partialhost = value; } }
        /// <summary>
        /// Where to Add
        /// </summary>
        public AddTo AddTo { get { return AddTo.Plugins; } }
        /// <summary>
        /// The Menu Items To Be Added To The Base Menu.
        /// </summary>
        public List<ToolStripMenuItem> MenuItems { get { return items;} }

            /// <summary>
            /// Name of the Plugin
            /// </summary>
            public string Name { get { return "Test Plugin"; } }
            /// <summary>
            /// Version of the Plugin
            /// </summary>
            public string Version { get { return "1.0"; } }
            /// <summary>
            /// Author of the Plugin
            /// </summary>
            public string Author { get { return "Ynote Classic"; } }
            /// <summary>
            /// Description of the Plugin
            /// </summary>
            public string Description { get { return "Sample Plugin."; } }
            List<ToolStripMenuItem> items;

            public void Dispose()
            {
                items = new List<ToolStripMenuItem>();
                ConstructMenuItem1();
                ConstructMenuItem2();
            }
            void ConstructMenuItem1()
            {
                ToolStripMenuItem item = new ToolStripMenuItem();
                item.Text = "Say Hello.";
                item.Click += new EventHandler(item_Click);
		items.Add(item);
            }
            void ConstructMenuItem2()
            {
                ToolStripMenuItem item2 = new ToolStripMenuItem();
                item2.Text = "Show Test Window";
                item2.Click += new EventHandler(item2_Click);
		items.Add(item2);
            }
            private void item2_Click(object sender, EventArgs e)
            {
                new Window(Host).Show(Host.Panel, WeifenLuo.WinFormsUI.Docking.DockState.DockRight);
            }
            private void item_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Hello, World!");
            }
    }
}
